package com.example.icampusevent;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class MapTag extends ItemizedOverlay {

	private ArrayList<OverlayItem> overlayTags = new ArrayList<OverlayItem>();
	private ArrayList<Long> eventList = new ArrayList<Long>();
	private Activity activity;
	
	public MapTag(Drawable marker) {
		super(boundCenterBottom(marker));
	}
	
	public MapTag(Drawable marker, Activity activity) {
		super(boundCenterBottom(marker));
		this.activity = activity;
	}
	
	public void addTag(OverlayItem tag) {
		overlayTags.add(tag);
		populate();
	}
	
	public void addEventId(Long eventId) {
		eventList.add(eventId);
	}
	
	public void clearTags() {
		overlayTags.clear();
		eventList.clear();
	}

	@Override
	protected OverlayItem createItem(int i) {
		return overlayTags.get(i);
	}

	@Override
	public int size() {
		return overlayTags.size();
	}
	
	@Override
	protected boolean onTap(int index) {
		// Navigate to event detail activity
		Intent intent = new Intent(activity, EventDetailActivity.class);
		intent.putExtra("EVENTID", eventList.get(index));
		intent.putExtra("USERID", ((MainActivity)activity).getUserId());
		intent.putExtra("MODE", 0);
		activity.startActivity(intent);
		
		return true;
	}

}
